Float

class Float : Number, Comparable<Float>

Represents a single-precision 32-bit IEEE 754 floating point number.

Types

Companion
Link copied to clipboard
object Companion

Functions

compareTo
Link copied to clipboard
operator fun compareTo(other: Byte): Int
operator fun compareTo(other: Double): Int
open operator override fun compareTo(other: Float): Int
operator fun compareTo(other: Int): Int
operator fun compareTo(other: Long): Int
operator fun compareTo(other: Short): Int

Compares this value with the specified value for order. Returns zero if this value is equal to the specified other value, a negative number if it's less than other, or a positive number if it's greater than other.

dec
Link copied to clipboard
operator external fun dec(): Float

Decrements this value.

div
Link copied to clipboard
inline operator fun div(other: Byte): Float
inline operator fun div(other: Double): Double
operator external fun div(other: Float): Float
inline operator fun div(other: Int): Float
inline operator fun div(other: Long): Float
inline operator fun div(other: Short): Float

Divides this value by the other value.

equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
fun equals(other: Float): Boolean
hashCode
Link copied to clipboard
open override fun hashCode(): Int
inc
Link copied to clipboard
operator external fun inc(): Float

Increments this value.

minus
Link copied to clipboard
inline operator fun minus(other: Byte): Float
inline operator fun minus(other: Double): Double
operator external fun minus(other: Float): Float
inline operator fun minus(other: Int): Float
inline operator fun minus(other: Long): Float
inline operator fun minus(other: Short): Float

Subtracts the other value from this value.

plus
Link copied to clipboard
inline operator fun plus(other: Byte): Float
inline operator fun plus(other: Double): Double
operator external fun plus(other: Float): Float
inline operator fun plus(other: Int): Float
inline operator fun plus(other: Long): Float
inline operator fun plus(other: Short): Float

Adds the other value to this value.

rem
Link copied to clipboard
inline operator fun rem(other: Byte): Float
inline operator fun rem(other: Double): Double
operator external fun rem(other: Float): Float
inline operator fun rem(other: Int): Float
inline operator fun rem(other: Long): Float
inline operator fun rem(other: Short): Float

Calculates the remainder of truncating division of this value by the other value.

times
Link copied to clipboard
inline operator fun times(other: Byte): Float
inline operator fun times(other: Double): Double
operator external fun times(other: Float): Float
inline operator fun times(other: Int): Float
inline operator fun times(other: Long): Float
inline operator fun times(other: Short): Float

Multiplies this value by the other value.

toByte
Link copied to clipboard
@DeprecatedSinceKotlin(warningSince = "1.3", errorSince = "1.5")
open override fun toByte(): Byte

Converts this Float value to Byte.

toChar
Link copied to clipboard
@DeprecatedSinceKotlin(warningSince = "1.5")
open override fun toChar(): Char

Converts this Float value to Char.

toDouble
Link copied to clipboard
open external override fun toDouble(): Double

Converts this Float value to Double.

toFloat
Link copied to clipboard
open inline override fun toFloat(): Float

Returns this value.

toInt
Link copied to clipboard
open external override fun toInt(): Int

Converts this Float value to Int.

toLong
Link copied to clipboard
open external override fun toLong(): Long

Converts this Float value to Long.

toShort
Link copied to clipboard
@DeprecatedSinceKotlin(warningSince = "1.3", errorSince = "1.5")
open override fun toShort(): Short

Converts this Float value to Short.

toString
Link copied to clipboard
open override fun toString(): String
unaryMinus
Link copied to clipboard
operator external fun unaryMinus(): Float

Returns the negative of this value.

unaryPlus
Link copied to clipboard
operator external fun unaryPlus(): Float

Returns this value.

Extensions

absoluteValue
Link copied to clipboard
expect val Float.absoluteValue: Float

Returns the absolute value of this value.

actual val Float.absoluteValue: Float

Returns the absolute value of this value.

actual val Float.absoluteValue: Float

Returns the absolute value of this value.

actual val Float.absoluteValue: Float

Returns the absolute value of this value.

coerceAtLeast
Link copied to clipboard
fun Float.coerceAtLeast(minimumValue: Float): Float

Ensures that this value is not less than the specified minimumValue.

coerceAtMost
Link copied to clipboard
fun Float.coerceAtMost(maximumValue: Float): Float

Ensures that this value is not greater than the specified maximumValue.

coerceIn
Link copied to clipboard
fun Float.coerceIn(minimumValue: Float, maximumValue: Float): Float

Ensures that this value lies in the specified range minimumValue..maximumValue.

IEEErem
Link copied to clipboard
inline fun Float.IEEErem(divisor: Float): Float

Computes the remainder of division of this value by the divisor value according to the IEEE 754 standard.

external fun Float.IEEErem(divisor: Float): Float

Computes the remainder of division of this value by the divisor value according to the IEEE 754 standard.

isFinite
Link copied to clipboard
expect fun Float.isFinite(): Boolean
actual inline fun Float.isFinite(): Boolean

Returns true if the argument is a finite floating-point value; returns false otherwise (for NaN and infinity arguments).

actual fun Float.isFinite(): Boolean

Returns true if the argument is a finite floating-point value; returns false otherwise (for NaN and infinity arguments).

actual external fun Float.isFinite(): Boolean

Returns true if the argument is a finite floating-point value; returns false otherwise (for NaN and infinity arguments).

isInfinite
Link copied to clipboard
expect fun Float.isInfinite(): Boolean
actual inline fun Float.isInfinite(): Boolean

Returns true if this value is infinitely large in magnitude.

actual fun Float.isInfinite(): Boolean

Returns true if this value is infinitely large in magnitude.

actual external fun Float.isInfinite(): Boolean

Returns true if this value is infinitely large in magnitude.

isNaN
Link copied to clipboard
expect fun Float.isNaN(): Boolean
actual inline fun Float.isNaN(): Boolean

Returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.

actual fun Float.isNaN(): Boolean

Returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.

actual external fun Float.isNaN(): Boolean

Returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.

mod
Link copied to clipboard
inline fun Float.mod(other: Float): Float
inline fun Float.mod(other: Double): Double

Calculates the remainder of flooring division of this value by the other value.

nextDown
Link copied to clipboard
inline fun Float.nextDown(): Float

Returns the Float value nearest to this value in direction of negative infinity.

external fun Float.nextDown(): Float

Returns the Float value nearest to this value in direction of negative infinity.

nextTowards
Link copied to clipboard
inline fun Float.nextTowards(to: Float): Float

Returns the Float value nearest to this value in direction from this value towards the value to.

external fun Float.nextTowards(to: Float): Float

Returns the Float value nearest to this value in direction from this value towards the value to.

nextUp
Link copied to clipboard
inline fun Float.nextUp(): Float

Returns the Float value nearest to this value in direction of positive infinity.

external fun Float.nextUp(): Float

Returns the Float value nearest to this value in direction of positive infinity.

pow
Link copied to clipboard
expect fun Float.pow(x: Float): Float

Raises this value to the power x.

expect fun Float.pow(n: Int): Float

Raises this value to the integer power n.

actual inline fun Float.pow(x: Float): Float

Raises this value to the power x.

actual inline fun Float.pow(n: Int): Float

Raises this value to the integer power n.

actual inline fun Float.pow(x: Float): Float

Raises this value to the power x.

actual inline fun Float.pow(n: Int): Float

Raises this value to the integer power n.

actual external fun Float.pow(x: Float): Float

Raises this value to the power x.

actual fun Float.pow(n: Int): Float

Raises this value to the integer power n.

rangeTo
Link copied to clipboard
operator fun Float.rangeTo(that: Float): ClosedFloatingPointRange<Float>

Creates a range from this Float value to the specified that value.

roundToInt
Link copied to clipboard
expect fun Float.roundToInt(): Int

Rounds this Float value to the nearest integer and converts the result to Int. Ties are rounded towards positive infinity.

actual fun Float.roundToInt(): Int

Rounds this Float value to the nearest integer and converts the result to Int. Ties are rounded towards positive infinity.

actual inline fun Float.roundToInt(): Int

Rounds this Float value to the nearest integer and converts the result to Int. Ties are rounded towards positive infinity.

actual fun Float.roundToInt(): Int

Rounds this Float value to the nearest integer and converts the result to Int. Ties are rounded towards positive infinity.

roundToLong
Link copied to clipboard
expect fun Float.roundToLong(): Long

Rounds this Float value to the nearest integer and converts the result to Long. Ties are rounded towards positive infinity.

actual fun Float.roundToLong(): Long

Rounds this Float value to the nearest integer and converts the result to Long. Ties are rounded towards positive infinity.

actual inline fun Float.roundToLong(): Long

Rounds this Float value to the nearest integer and converts the result to Long. Ties are rounded towards positive infinity.

actual fun Float.roundToLong(): Long

Rounds this Float value to the nearest integer and converts the result to Long. Ties are rounded towards positive infinity.

sign
Link copied to clipboard
expect val Float.sign: Float

Returns the sign of this value:

actual val Float.sign: Float

Returns the sign of this value:

actual val Float.sign: Float

Returns the sign of this value:

actual val Float.sign: Float

Returns the sign of this value:

toBigDecimal
Link copied to clipboard
inline fun Float.toBigDecimal(): BigDecimal
inline fun Float.toBigDecimal(mathContext: MathContext): BigDecimal

Returns the value of this Float number as a BigDecimal.

toBits
Link copied to clipboard
expect fun Float.toBits(): Int

Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout.

actual inline fun Float.toBits(): Int

Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout.

actual fun Float.toBits(): Int

Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout.

actual inline fun Float.toBits(): Int

Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout.

toRawBits
Link copied to clipboard
expect fun Float.toRawBits(): Int

Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout, preserving NaN values exact layout.

actual inline fun Float.toRawBits(): Int

Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout, preserving NaN values exact layout.

actual fun Float.toRawBits(): Int

Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout, preserving NaN values exact layout.

actual inline fun Float.toRawBits(): Int

Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout, preserving NaN values exact layout.

toUInt
Link copied to clipboard
inline fun Float.toUInt(): UInt

Converts this Float value to UInt.

toULong
Link copied to clipboard
inline fun Float.toULong(): ULong

Converts this Float value to ULong.

ulp
Link copied to clipboard
val Float.ulp: Float

Returns the ulp of this value.

val Float.ulp: Float
withSign
Link copied to clipboard
expect fun Float.withSign(sign: Float): Float
expect fun Float.withSign(sign: Int): Float

Returns this value with the sign bit same as of the sign value.

actual inline fun Float.withSign(sign: Float): Float
actual inline fun Float.withSign(sign: Int): Float

Returns this value with the sign bit same as of the sign value.

actual inline fun Float.withSign(sign: Float): Float
actual inline fun Float.withSign(sign: Int): Float

Returns this value with the sign bit same as of the sign value.

actual external fun Float.withSign(sign: Float): Float
actual fun Float.withSign(sign: Int): Float

Returns this value with the sign bit same as of the sign value.